package sword.T14;

/**
 * @File Info: leetcode -- <Solution>
 * @Author: 18362
 * @Create: 2022-03-23 16:01:33 星期三
 */

class Solution {
    public int cuttingRope(int n) {
        int[] dp = new int[n+1];
        dp[0] = 1;
        dp[1] = 1;
        for (int i=2; i<=n; ++i) {
            for (int j=1; j<i; ++j) {
                int temp = Math.max(dp[i-j]*j, (i-j)*j);
                dp[i] = Math.max(dp[i], temp);
            }
        }
        return dp[n];
    }
}